{% extends "./inc/base.html" %}
{% if 4|getmode('')|length==0 %}
{%set ism = 5%}
{%else%}
{%set ism = 0%}
{%endif%}
{% block content %}
<section class="vbox">
    <header class="header bg-light dk">
        <ul class="nav nav-tabs pull-left">
            {% for ingredient, amount in config.setup.CONFIG_GROUP_LIST %}
            {%if ingredient != ism%}
            <li {%if id == ingredient %}class="active"{% endif %} ><a href="/admin/setup/index?id={{ ingredient }}"  data-groupid="{{ ingredient }}" class="grouplist"> {{ amount }}</a></li>
            {%endif%}
            {% endfor %}
        </ul>
    </header>
    <section class="scrollable wrapper">

  <section class="panel panel-default">
                <header class="panel-heading font-bold">
                  {{meta_title}}
                </header>
                <div class="panel-body">
                  <form method="post" action="/admin/setup/save" class="form-horizontal" id="ajaxForm">
                  {% for item in list %}  
                 
                    <div class="form-group">
                      <label class="col-sm-2 control-label">{{ item.title }}</label>
                      <div class="col-sm-10">
                          <div class="row">
                        {% if item.type == 0 %}
                              <div class="col-md-3">
                          <input type="text" class="form-control" name="{{item.name}}" value="{{ item.value }}">
                              </div>
                        {% elif item.type == 1 %}
                              <div class="col-md-10">
                         <input type="text" class="form-control" name="{{item.name}}" value="{{ item.value }}">
                                  </div>
                        {% elif item.type == 2 %}
                              <div class="col-md-10">
                         <textarea class="form-control" name="{{item.name}}"  style="height: 100px">{{ item.value }}</textarea>
                         </div>
                         {% elif item.type == 3 %}
                              <div class="col-md-5">
                          <textarea class="form-control" name="{{item.name}}"  style="height: 100px">{{ item.value }}</textarea>
                              </div>
                         {% elif item.type == 4 %}
                              <div class="col-md-3">
                         <select class="form-control " name="{{item.name}}">
                             {% for index, items in item.extra|parse_config_attr %}
                          <option value="{{index}}" {% if item.value == index %} selected {% endif %}>{{items}}</option>
                             {% endfor%}
                         </select>
                                  </div>
                        {% endif %}
                              <div class="col-md-12">
                                  <code>this.config('setup.{{item.name}}')</code>
                                  <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>  {{item.remark|safe}}</span>
                              </div>
                          </div>
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    {% endfor %}

                    <div class="form-group form-submit">
                      <div class="col-sm-4 col-sm-offset-2">
                           <button class="btn btn-primary" type="submit" id="btn">确定</button>
                        <button class="btn btn-default" onclick="javascript:history.back(-1);return false;" type="submit">返回</button>
                       
                      </div>
                    </div>
                  </form>
                </div>
              </section>

     </section>
     
    </section>
</section>

{% endblock %}
{% block script%}
<script type="text/javascript">
    $(function(){
        $('#ajaxForm #btn').on('click', function () {
            var jsonData = $('#ajaxForm').serialize();
            $.ajax({
                type:"POST",
                url: "/admin/setup/save",
                data: jsonData,
                success: function (data) {
                    toastr.success('配置成功!')
                    window.location.reload();
                }
            });
            return false;
        });
    })


    </script>
{% endblock%}